import { createRouter,createWebHashHistory,createWebHistory } from "vue-router";
const routes = [
    {
        path:'/register',
        name:'register',
        component:() => import('@/views/Register.vue')
    },
    {
        path:'/login',
        name:'login',
        component:() => import ("@/views/Login.vue")
    },
    {
        path:'/home',
        name:'home',
        component:() => import('@/views/Home.vue'),
        children :[
            {
                path:'/home/one',
                name:'one',
                component:() => import('@/views/home/One.vue')
            },
            {
                path:'/home/two',
                name:'two',
                component:() => import('@/views/home/Two.vue'),
                beforeEnter :()=>{
                    console.log('路由独享');
                    
                }
            }
        ]
    },
    {
        path:'/',
        redirect:{
            path:'/home'
        }
    }
]

const router = createRouter({
    history:createWebHistory(),
    routes
});

router.beforeEach((to,from,next) =>{
    console.log(to);
    console.log(from);
    next();  
})
export default router;